package my.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

public class Config {
	private static Properties p;
	static {
		p = new Properties();
		InputStreamReader reader = null;
		try {
			reader = new InputStreamReader(
					Config.class.getResourceAsStream("/config.properties"));
			p.load(reader);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				reader.close();
			} catch (IOException e) {
			}
		}
	}

	public static String getValue(String name) {
		String s = p.getProperty(name);
		if (s == null)
			s = "";
		return s;
	}

	public static int getInt(String name) {
		String v = getValue(name);
		return v.length() == 0 ? 0 : Integer.valueOf(v);
	}

	public static String getDownloadPath() {
		return getValue("downloadpath");
	}

	public static boolean getBoolean(String name) {
		String v = getValue(name).toLowerCase();
		return v.equals("true") || v.equals("1") || v.equals("t");
	}
}
